package com.fireowlf.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
import org.springframework.context.annotation.Bean;

import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;

@SpringBootApplication
public class FastJsonApplication2 {

	public static void main(String[] args) {
		SpringApplication.run(FastJsonApplication2.class, args);
	}

	@Bean
	public HttpMessageConverters fastJsonConvertors() {
		// 1.定义消息转换对象
		FastJsonHttpMessageConverter fastConvertor = new FastJsonHttpMessageConverter();
		// 2.添加fastjson的配置消息
		FastJsonConfig fastConf = new FastJsonConfig();
		fastConf.setSerializerFeatures(SerializerFeature.PrettyFormat);// 设置让json格式化
		// 3.将配置信息添加到转换对象中
		fastConvertor.setFastJsonConfig(fastConf);
		return new HttpMessageConverters(fastConvertor);

	}
}
